package com.activenetwork.smlite.testcase.events.createEvents.basics;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.activenetwork.schema.model.event.EventBasicType;
import com.activenetwork.smlite.page.event.EventDetailView.EventBasicSubview;
import com.activenetwork.smlite.snippet.EventsSnippet;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.RandomString;
import com.activenetwork.util.verification.gson.FailureAssertion;

public class Basics007 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(Basics007.class);
	private EventBasicType.Location bucharest;
	
	@BeforeClass(alwaysRun = true)
	public void dataSetup() {
		bucharest = new EventBasicType.Location();
		bucharest.setLocationName("Bucharest" + "-" + RandomString.generateRandomString(5));
		bucharest.setAddress("address line 1");
		bucharest.setAddressContinue("address line 2");
		bucharest.setCityRegion("Bucharest");
		bucharest.setStateProvince("BU");
		bucharest.setPostalCode("200032");
		bucharest.setCounty("AG");
		bucharest.setPrivate(true);
	}
	
	@Test(groups = "repair")
	public void Verify_duplicate_location_can_not_be_allowed_to_create(){
		loginBusiness.login();
		
		// Add this unique location for first time
		EventBasicSubview eventBasicSubview = EventsSnippet.gotoAddEventPage();
		
		EventBasicType bucharestEvent = new EventBasicType();
		bucharestEvent.setLocation(bucharest);
		eventBasicSubview.setEventLocation(bucharestEvent);
		eventBasicSubview.saveLocation();
		
		// Add this location again
		eventBasicSubview = EventsSnippet.gotoAddEventPage();
		eventBasicSubview.setEventLocation(bucharestEvent);
		eventBasicSubview.saveLocation();
		
		// logout
		loginBusiness.logout();
		FailureAssertion.pop(Basics007.class);
	}
}
